package com.opencvjava.lessons.core;

import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.core.Point3;
import org.opencv.core.Range;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.springframework.stereotype.Service;

import static com.opencvjava.support.util.CvUtils.mat;
import static com.opencvjava.support.util.CvUtils.matDataStr;
import static org.opencv.core.CvType.CV_8U;
import static org.opencv.core.CvType.CV_8UC2;
import static org.opencv.core.CvType.CV_8UC3;

@Service
public class L2_CoreModule {
    public void test() {
//        Mat - The Basic Image Container
        Mat a, c;
        a = mat("lena.jpg");
        Mat b = new Mat(a.size(), a.type());
        c = a;
        Rect r = new Rect(100, 100, 10, 10);
        Mat D = new Mat(a, r);
        Mat e = new Mat(a, Range.all(), new Range(0, 10));
        Mat smallImg = a.submat(r);
        Mat f = a.clone();
        Mat g = new Mat();
        a.copyTo(g);
        Mat m = new Mat(3, 3, CV_8UC3, new Scalar(0, 0, 255));
        System.out.println("m data str: " + matDataStr(m));
        Mat m1 = new Mat(5, 3, CV_8UC2, new Scalar(0, 255));
        System.out.println("m1 data str: " + matDataStr(m1));
        Mat m2 = Mat.eye(4, 4, CV_8U);
        System.out.println("m2 data str: " + matDataStr(m2));
        Point p = new Point(2, 1);
        System.out.println("point : " + p);
        Point3 p3 = new Point3(2, 1, 3);
        System.out.println("point3 : " + p3);
    }
}
